package com.pm.service.dept.impl;

import com.pm.entity.po.dept.Department;
import com.pm.entity.po.dept.DepartmentType;
import com.pm.entity.po.dept.DeptNamePo;
import com.pm.entity.po.task.Task;
import com.pm.entity.vo.dept.DeptVO;
import com.pm.mapper.dept.DepartmentMapper;
import com.pm.service.dept.DepartmentService;
import com.pm.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DepartmentServiceImpl extends BaseServiceImpl<Department> implements DepartmentService {
    private DepartmentMapper departmentMapper;

    @Resource
    private void setBaseMapper(DepartmentMapper departmentMapper) {
        this.departmentMapper = departmentMapper;
        super.setBaseMapper(departmentMapper);
    }

    /*
     * (non-Javadoc) <p>Title: getListByType</p> <p>Description: </p>
     *
     * @return
     *
     * @see com.pm.service.dept.DepartmentService#getListByType()
     */
    @Override
    public List<DepartmentType> getListByType() {
        List<DepartmentType> depts = departmentMapper.getListByType();
        Department dept = new Department();
        for (DepartmentType t : depts) {
            dept.setDepartmentTypeId(t.getId());
            t.setDepartments(departmentMapper.getList(dept));
        }
        return depts;
    }

    @Override
    public List<DepartmentType> getListByTypeNotFive() {
        List<DepartmentType> depts = departmentMapper.getListByTypeNotFive();
        Department dept = new Department();
        for (DepartmentType t : depts) {
            dept.setDepartmentTypeId(t.getId());
            //t.setDepartments(departmentMapper.getList(dept));
            t.setDepartments(departmentMapper.getHaveTaskList(dept));
        }
        return depts;
    }

    @Override
    public List<DepartmentType> getHaveScoreDeptList() {
        List<DepartmentType> depts = departmentMapper.getListByTypeNotFive();
        Department dept = new Department();
        for (DepartmentType t : depts) {
            dept.setDepartmentTypeId(t.getId());
            //t.setDepartments(departmentMapper.getList(dept));
            t.setDepartments(departmentMapper.getHaveScoreDeptList(dept));
        }
        return depts;
    }

    @Override
    public List<Department> Departments(Integer id) {
        return departmentMapper.Departments(id);
    }

    @Override
    public List<DepartmentType> getAllDepartmentT(Integer id) {
        return departmentMapper.getAllDepartmentT(id);
    }

    /* (non-Javadoc)
     * <p>Title: getDeptVOList</p>
     * <p>Description: </p>
     * @param id
     * @return
     * @see com.pm.service.dept.DepartmentService#getDeptVOList(java.lang.Integer)
     */
    @Override
    public List<DeptVO> getDeptVOList(Integer id) {
        return departmentMapper.getDeptVOList(id);
    }

    /* (non-Javadoc)
     * <p>Title: getTaskList</p>
     * <p>Description: </p>
     * @param task
     * @return
     * @see com.pm.service.dept.DepartmentService#getTaskList(com.pm.entity.po.task.Task)
     */
    @Override
    public List<Task> getTaskList(Task task) {
        return departmentMapper.getTaskList(task);
    }

    @Override
    public List<DeptNamePo> getAllDeptName() {
        return departmentMapper.getAllDeptName();
    }

}
